package com.ruoyi.system.BusinessContract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.BusinessContract.domain.BusinessContract;
import com.ruoyi.system.BusinessContract.service.IBusinessContractService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * BussinessContractController
 * 
 * @author ruoyi
 * @date 2025-04-24
 */
@RestController
@RequestMapping("/BussinessContract/contractmanadge")
public class BusinessContractController extends BaseController
{
    @Autowired
    private IBusinessContractService businessContractService;

    /**
     * 查询BussinessContract列表
     */
    @PreAuthorize("@ss.hasPermi('BussinessContract:contractmanadge:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessContract businessContract)
    {
        startPage();
        List<BusinessContract> list = businessContractService.selectBusinessContractList(businessContract);
        return getDataTable(list);
    }

    /**
     * 导出BussinessContract列表
     */
    @PreAuthorize("@ss.hasPermi('BussinessContract:contractmanadge:export')")
    @Log(title = "BussinessContract", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessContract businessContract)
    {
        List<BusinessContract> list = businessContractService.selectBusinessContractList(businessContract);
        ExcelUtil<BusinessContract> util = new ExcelUtil<BusinessContract>(BusinessContract.class);
        util.exportExcel(response, list, "BussinessContract数据");
    }

    /**
     * 获取BussinessContract详细信息
     */
    @PreAuthorize("@ss.hasPermi('BussinessContract:contractmanadge:query')")
    @GetMapping(value = "/{contractId}")
    public AjaxResult getInfo(@PathVariable("contractId") String contractId)
    {
        return success(businessContractService.selectBusinessContractByContractId(contractId));
    }

    /**
     * 新增BussinessContract
     */
    @PreAuthorize("@ss.hasPermi('BussinessContract:contractmanadge:add')")
    @Log(title = "BussinessContract", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessContract businessContract)
    {
        return toAjax(businessContractService.insertBusinessContract(businessContract));
    }

    /**
     * 修改BussinessContract
     */
    @PreAuthorize("@ss.hasPermi('BussinessContract:contractmanadge:edit')")
    @Log(title = "BussinessContract", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessContract businessContract)
    {
        return toAjax(businessContractService.updateBusinessContract(businessContract));
    }

    /**
     * 删除BussinessContract
     */
    @PreAuthorize("@ss.hasPermi('BussinessContract:contractmanadge:remove')")
    @Log(title = "BussinessContract", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractIds}")
    public AjaxResult remove(@PathVariable String[] contractIds)
    {
        return toAjax(businessContractService.deleteBusinessContractByContractIds(contractIds));
    }
}
